package com.bwie.goods.controller;

import com.bwie.common.domain.Shop;
import com.bwie.common.result.Result;
import com.bwie.goods.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/Shop")
public class ShopController {
    @Autowired
    private ShopService shopService;

    /**
     * 查询商品列表
     * @return
     */
    @GetMapping("/list")
    public Result<List<Shop>> list(){
        Result<List<Shop>> list=shopService.list();
        return list;
    }

    /**
     * 上传图片
     * @param file
     * @return
     */
    @PostMapping("/upload")
    public Result upload(@RequestParam("file") MultipartFile file){
        Result result=shopService.upload(file);
        return result;
    }

    /**
     * 添加到购物车
     */
    @PostMapping("/ShoppingAdd")
    public Result ShoppingAdd(@RequestBody Shop shop){
        Result result=shopService.ShoppingAdd(shop);
        return result;
    }

    /**
     * 商品上架
     * @param id
     * @return
     */
    @PostMapping("/ShopUpFlag/{id}")
    public Result ShopUpFlag(@PathVariable Integer id){
        Result result=shopService.ShopUpFlag(id);
        return result;
    }

    /**
     * 商品下架
     * @param id
     * @return
     */
    @PostMapping("/ShopUpdateFlag/{id}")
    public Result ShopUpdateFlag(@PathVariable Integer id){
        Result result=shopService.ShopUpdateFlag(id);
        return result;
    }


}
